package com.eshop.eshopmanagersystem.idal;

import com.eshop.eshopmanagersystem.model.EchartsInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface IEchartsDAL {
    /**
     * 统计最近7天的数据并按天分组
     *
     */
    @Select("SELECT \n" +
            "SUM(sum) as sum,cast(SUM(total_price) AS DECIMAL(10,2)) AS total_price,DATE_FORMAT(create_time,'%Y/%m/%d') as days\n" +
            "FROM order_tb \n" +
            "WHERE DATE_SUB(CURRENT_DATE,INTERVAL 7 DAY)<=DATE(create_time) GROUP BY days;")
    public List<EchartsInfo> getEchartTableBySevenDays();

}
